package image;

import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;

import org.jfree.ui.tabbedui.VerticalLayout;

public class CalibrationFrame extends JFrame {
	private static final long serialVersionUID = -5101472965943852691L;

	public CalibrationFrame() {
		JFrame f = this;
		
		JPanel p = new JPanel(new VerticalLayout());
		for(int i = 0; i<4; i++) {
			final int index = i;
			JPanel up = new JPanel();
			up.setBorder(BorderFactory.createDashedBorder(ImageMain.color[i]));
			NumberEditor valEd = new NumberEditor(0, 255, ImageMain.minValue[i], ImageMain.componentNames[i]+" value", 1);
			valEd.setPreferredSize(new Dimension(256, valEd.getPreferredSize().height));
			valEd.addPropertyChangeListener(new PropertyChangeListener() {
				@Override
				public void propertyChange(PropertyChangeEvent e) {
					ImageMain.minValue[index] = (Integer)e.getNewValue();
				}});
			NumberEditor satEd = new NumberEditor(0, 255, ImageMain.minValue[i], ImageMain.componentNames[i]+" saturation", 1);
			satEd.addPropertyChangeListener(new PropertyChangeListener() {
				@Override
				public void propertyChange(PropertyChangeEvent e) {
					ImageMain.minSaturation[index] = (Integer)e.getNewValue();
				}});
			satEd.setPreferredSize(new Dimension(256, satEd.getPreferredSize().height));
			up.add(valEd);
			up.add(satEd);
			p.add(up);
		}
		
		f.add(p);
		f.pack();
		f.setVisible(true);
	}

}
